<?php

class CategoryPeer extends BaseCategoryPeer
{

	static public function doSelectOrderByI18nName($c){
	    //$c= new Criteria();
	    $c->addJoin(self::ID, CategoryI18nPeer::ID);
	    $c->addAscendingOrderByColumn( CategoryI18nPeer::NAME);
	    $c->setDistinct();
	    
	    
	    return self::doSelect($c);
	}
	static public function getOrCreateByName($name)
	{
		$c = new Criteria();
		$c->addJoin(self::ID,CategoryI18nPeer::ID );
		$c->add(CategoryI18nPeer::NAME , $name);

		$obj = self::doSelectOne($c);


		if(!$obj){
			$obj = new Category();
			$obj->setName($name);
			$obj->save();
		}
		return  $obj ;
	}
	

}
